<!DOCTYPE HTML>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
	<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
	<title>Hello APP</title>
	<link rel="stylesheet" type="text/css" href="../../css/aui-flex.css" />
	<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
	<link rel="stylesheet" type="text/css" href="../../css/common.css" />
	<style>
		.aui-pull-right {
			color: #363436 !important;
			font-size: 0.8rem;
		}
	</style>
</head>

<body>
	<header class="aui-bar aui-bar-nav aui-bar-light" id="header">
		<div class="aui-pull-left back" tapmode onclick="api.closeWin()"></div>
		<div class="aui-title">新增收货地址</div>
		<div class="aui-pull-right aui-hide" tapmode onclick="delAddr()">删除</div>
	</header>
</body>
<script type="text/javascript" src="../../script/import.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
var addressId;
	apiready = function() {
		api.parseTapmode();
		var header = $api.byId('header');
		$api.fixStatusBar(header);
		var headerH = $api.offset(header).h;
		api.openFrame({
			name: 'add_address_frm',
			url: 'add_address_frm.html',
			rect: {
				x: 0,
				y: headerH,
				w: 'auto',
				h: 'auto'
			},
			pageParam: api.pageParam
		});
		addressId = api.pageParam.itemId;
		
		if (api.pageParam.editAddr) {
			$$('.aui-title').text(api.pageParam.editAddr);
			$$('.aui-pull-right').removeClass('aui-hide')
		}
	};

	function delAddr() {
		var confirmMaskTxt = ['确认删除收货地址？', '取消', '确认'];
		openConfirmMask(confirmMaskTxt, 'del('+ addressId +')');
	}
	function del(Id){
		// var _this = Id;
		api.ajax({
			url: BASE_URL + 'App/User/deleteAddress',
			method: 'post',
			data: {
				values: {
					address_id: Id
				}
			}
		},function(ret, err){
			if (ret) {
				if(ret.code == 1){
					api.execScript({
						name: 'address_win',
						frameName: 'address_frm',
						script: 'getAdrList();'
					});
					setTimeout(function(){
						api.closeWin();
					},1000);
					toast(ret.msg);
				}else{
					toast(ret.msg);
				}
			}
		});
	}
	// function delConfirm(id) {
	// 	toast('是的')
	// }

</script>

</html>
